<{if $data.associate == 'true'}>
<{script src="coms/autocompleter.js" app='desktop'}>
<{css src="component.css" app='desktop'}>
<{/if}>
<form action="<{link app=b2c ctl=site_search act=result }>" method="post" class="SearchBar">
  <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="3" class="search_label"> <span><{t app='b2c'}>关键字：<{/t}></span> </td>
    </tr>
    <tr>
      <td colspan="3"> <input type="text" name="name[]"  autocompleter="associate_autocomplete_goods:name,goods_id" ac_options="{relative:false} class="inputstyle keywords"  /></td>
    </tr>
    <{if $setting.searchopen}>
    <tr>
      <td colspan="3" class="search_label"><span><{t app='b2c'}>价格筛选：<{/t}></span></td>
    </tr>
    <tr>
      <td class="search_price1"><{t app='b2c'}>价格从 <{/t}><{input name="price[0]" type="number" size="8" class="inputstyle" }></td>
      <td class="search_price2"><{t app='b2c'}>到 <{/t}><{input name="price[1]" type="number" size="8" class="inputstyle"}></td>
    </tr>
  <{/if}>
    <tr>
      <td colspan="3" class="search_btnbar">
      <input type="submit" value="<{t app='b2c'}>搜索<{/t}>" class="btn_search"/>
      <a href="<{link app=b2c ctl=site_search act=index }>" class="btn_advsearch"><{t app='b2c'}>高级搜索<{/t}></a></td>
    </tr>
  </table>
</form>

<{if $data.associate == 'true'}>
<script>
(function(scope){

	$(scope).getElements('input[autocompleter]').each(function(item) {
                 item.setAttribute('autocomplete','off');
                 var params = item.get('autocompleter');
                 var callUrl = '<{link app=associate ctl=site_associate act=index}>?param='+params;

                 var _getVar = params.match(/:([^,]*)/)[1];


                item.addEvent('keydown', function(e) {if (e.code == 13)e.stop();});
                var _base_options = {
                     getVar: _getVar,
                     fxOptions: false,
                     delay: 300,
                     callJSON: function() {return window.autocompleter_json;},
                     injectChoice: function(json) {
                         var token = json[this.options.getVar];
                         var choice = new Element('li', {'html': this.markQueryValue(token)});
                         choice.inputValue = token;
                         this.addChoiceEvents(choice).inject(this.choices);
                     }
                };
                var ac_options = {};
                try {
                    ac_options = JSON.decode(item.get('ac_options'));
                    Object.append(ac_options, item.retrieve('ac_options', {}));
                }catch (e) {}

                var _options = Object.merge(_base_options, ac_options);

                new Autocompleter.script(item, callUrl, _options);

       });


})(document.getElement('.SearchBar'));
</script>
<{/if}>